package com.weetop.aklyscan.presenter;

import android.app.Activity;

import com.weetop.aklyscan.base.mvp.BaseModel;
import com.weetop.aklyscan.base.mvp.BaseObserver;
import com.weetop.aklyscan.base.mvp.BasePresenter;
import com.weetop.aklyscan.bean.UserInfoBean;
import com.weetop.aklyscan.bean.VersionBean;
import com.weetop.aklyscan.view.LoginView;

public class LoginPresent extends BasePresenter<LoginView> {

    public LoginPresent(LoginView baseView, Activity activity) {
        super(baseView, activity);
    }

    public void login(String username , String password, String port){
        addDisposable(apiServer.login(username,password,port), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.loginSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void getVersion(){
        addDisposable(apiServer.Into23(), new BaseObserver<BaseModel<VersionBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<VersionBean> o) {
                baseView.getInto23Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into44(String print_equipment, String print_ip, String print_ssid, String print_mac, String print_paper_width, String print_paper_height,
                       String print_deviation_x, String print_deviation_y) {
        addDisposable(apiServer.Into44(print_equipment, print_ip, print_ssid, print_mac, print_paper_width, print_paper_height, print_deviation_x,
                print_deviation_y), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto44Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into45() {
        addDisposable(apiServer.Into45(), new BaseObserver<BaseModel<UserInfoBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<UserInfoBean> o) {
                baseView.getInto45Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

}
